<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view('common/head');?>
<body class="no-skin">
<?php $this->load->view('common/header');?>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <?php $this->load->view('common/sidebar');?>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <?php $this->load->view('common/breadcrumbs');?>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">

                <?php $this->load->view('common/set');?>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" action="<?php echo site_url(X_URL.'charge/update');?>" method="post">
						<?php echo csrf_hidden();?>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 项目名 </label>
                                <div class="col-sm-9">
                                    <select id="project_id" name="project_id" class="multiselect">
                                        <option value='0'>请选择项目</option>
                                        <?php if(isset($projects) && !empty($projects)){
                                            foreach ($projects as $key=>$val){?>
                                                <option value="<?php echo $val['project_id']?>" <?php if(isset($charge) && $val['project_id']==$charge['project_id']){echo 'selected="selected"';}?>><?php echo $val['project_name']?></option>
                                            <?php } }?>
                                    </select>
                                    <input type="hidden" name="charge_id" value="<?php if(isset($charge)){ echo $charge["charge_id"];}?>">
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 收款金额 </label>
                                <div class="col-sm-9">
                                    <input type="text" class="rcol-xs-10 col-sm-5" name="charge_money" id="charge_money" value="<?php if(isset($charge)){ echo $charge["charge_money"];}?>" <?php if(isset($charge)){ echo "disabled='disabled'";}?>>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 备注 </label>
                                <div class="col-sm-9">
                                    <textarea class="col-xs-10 col-sm-5" rows="4" id="charge_text" name="charge_text"><?php if(isset($charge)){ echo $charge["charge_text"];}?></textarea>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <?php $this->load->view('common/footer');?>
</div><!-- /.main-container -->

<?php $this->load->view('common/footerjs');?>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {
        $(".btn-info").click(function () {
            var project_id = $("#project_id").val();
            var charge_money = $("#charge_money").val();
            if(project_id== '0'){
                bootbox.dialog({
                    title:"系统提示",
                    message: "请选择项目",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return false;
            }

            if(charge_money== ''){
                bootbox.dialog({
                    title:"系统提示",
                    message: "请填写金额",
                    buttons: {
                        "success": {
                            "label": "确定",
                            "className": "btn-danger"
                        }
                    }
                });
                return false;
            }
            $("#form").submit();
        })
    })

</script>
</body>
</html>
